package com.jxdinfo.hussar.cloud.module.labor.xgfgl.lwt071relatedpartiesperson.service.impl;

import com.jxdinfo.hussar.support.mp.base.service.impl.HussarServiceImpl;
import com.jxdinfo.hussar.support.datasource.annotations.HussarDs;
import com.jxdinfo.hussar.platform.core.utils.HussarUtils;
import com.jxdinfo.hussar.support.exception.HussarException;
import com.jxdinfo.hussar.cloud.module.labor.xgfgl.lwt071relatedpartiesperson.model.Lwt071RelatedPartiesPerson;
import com.jxdinfo.hussar.cloud.module.labor.xgfgl.lwt071relatedpartiesperson.service.Lwt071RelatedPartiesPersonService;
import com.jxdinfo.hussar.cloud.module.labor.xgfgl.lwt071relatedpartiesperson.dao.Lwt071RelatedPartiesPersonMapper;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import com.jxdinfo.hussar.cloud.module.labor.xgfgl.lwt071relatedpartiesperson.vo.Lwt071RelatedPartiesPersonPageVO;
import com.jxdinfo.hussar.cloud.module.labor.xgfgl.lwt071relatedpartiesperson.dto.Lwt071RelatedPartiesPersonLwt071relatedpartiespersondataset1;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import java.util.Map;
import com.jxdinfo.hussar.support.mp.base.query.generator.SingleTableQueryGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashMap;
import com.jxdinfo.hussar.support.mp.base.query.generator.superquery.SuperQueryGenerator;
import com.jxdinfo.hussar.platform.core.base.apiresult.ApiResponse;

/**
 * 相关方人员表服务实现类
 */
@Service("xgfgl.lwt071relatedpartiesperson.Lwt071RelatedPartiesPersonServiceImpl")
@HussarDs("master")
public class Lwt071RelatedPartiesPersonServiceImpl extends HussarServiceImpl<Lwt071RelatedPartiesPersonMapper, Lwt071RelatedPartiesPerson> implements Lwt071RelatedPartiesPersonService {

    private static final Logger logger = LoggerFactory.getLogger(Lwt071RelatedPartiesPersonServiceImpl.class);

    private static final String RETURN_CODE = "0";

    @Autowired
    private Lwt071RelatedPartiesPersonMapper lwt071RelatedPartiesPersonMapper;

    @Override
    public ApiResponse<Lwt071RelatedPartiesPersonPageVO> hussarQueryPage(Page<Lwt071RelatedPartiesPerson> page) {
        try {
            Page<Lwt071RelatedPartiesPerson> pager = new Page<>(page.getCurrent(), page.getSize());
            Map<String, String[]> parameterMap = new HashMap<>();
            String[] orderParameter = new String[1];
            if (page.orders() != null) {
                for (OrderItem orderItem : page.orders()) {
                    if (orderItem.isAsc()) {
                        orderParameter[0] = orderItem.getColumn() + ",asc;";
                    } else {
                        orderParameter[0] = orderItem.getColumn() + ",desc;";
                    }
                }
            }
            parameterMap.put("orderRule", orderParameter);
            Lwt071RelatedPartiesPersonPageVO lwt071RelatedPartiesPersonPageVO = new Lwt071RelatedPartiesPersonPageVO();
            // 查询条件构造器,将排序条件封装成QueryWrapper
            SingleTableQueryGenerator singleTableQueryGenerator = new SingleTableQueryGenerator();
            QueryWrapper<Lwt071RelatedPartiesPerson> queryWrapper = singleTableQueryGenerator.initQueryWrapper(new Lwt071RelatedPartiesPerson(), parameterMap);
            List<Lwt071RelatedPartiesPerson> list = this.page(pager, queryWrapper).getRecords();
            lwt071RelatedPartiesPersonPageVO.setData(list);
            lwt071RelatedPartiesPersonPageVO.setCount(pager.getTotal());
            lwt071RelatedPartiesPersonPageVO.setCode(RETURN_CODE);
            return ApiResponse.success(lwt071RelatedPartiesPersonPageVO);
        } catch (Exception e) {
            throw new HussarException("表格查询失败");
        }
    }

    @Override
    public ApiResponse<Lwt071RelatedPartiesPersonPageVO> hussarQueryPage_order_custom(Page<Lwt071RelatedPartiesPerson> page) {
        try {
            Page<Lwt071RelatedPartiesPerson> pager = new Page<>(page.getCurrent(), page.getSize());
            Map<String, String[]> parameterMap = new HashMap<>();
            String[] orderParameter = new String[1];
            if (page.orders() != null) {
                for (OrderItem orderItem : page.orders()) {
                    if (orderItem.isAsc()) {
                        orderParameter[0] = orderItem.getColumn() + ",asc;";
                    } else {
                        orderParameter[0] = orderItem.getColumn() + ",desc;";
                    }
                }
            }
            parameterMap.put("orderRule", orderParameter);
            Lwt071RelatedPartiesPersonPageVO lwt071RelatedPartiesPersonPageVO = new Lwt071RelatedPartiesPersonPageVO();
            // 查询条件构造器,将排序条件封装成QueryWrapper
            SingleTableQueryGenerator singleTableQueryGenerator = new SingleTableQueryGenerator();
            QueryWrapper<Lwt071RelatedPartiesPerson> queryWrapper = singleTableQueryGenerator.initQueryWrapper(new Lwt071RelatedPartiesPerson(), parameterMap);
            List<Lwt071RelatedPartiesPerson> list = this.page(pager, queryWrapper).getRecords();
            lwt071RelatedPartiesPersonPageVO.setData(list);
            lwt071RelatedPartiesPersonPageVO.setCount(pager.getTotal());
            lwt071RelatedPartiesPersonPageVO.setCode(RETURN_CODE);
            return ApiResponse.success(lwt071RelatedPartiesPersonPageVO);
        } catch (Exception e) {
            throw new HussarException("表格查询失败");
        }
    }

    @Override
    public ApiResponse<Lwt071RelatedPartiesPersonPageVO> hussarQuerylwt071RelatedPartiesPersonCondition_1Page(Lwt071RelatedPartiesPersonLwt071relatedpartiespersondataset1 lwt071relatedpartiespersondataset1) {
        try {
            Lwt071RelatedPartiesPersonPageVO lwt071RelatedPartiesPersonPageVO = new Lwt071RelatedPartiesPersonPageVO();
            Page<Lwt071RelatedPartiesPerson> pager = new Page<>(lwt071relatedpartiespersondataset1.getCurrent(), lwt071relatedpartiespersondataset1.getSize());
            Map<String, String[]> parameterMap = new HashMap<>();
            String[] orderParameter = new String[1];
            if (lwt071relatedpartiespersondataset1.getOrders() != null) {
                for (OrderItem orderItem : lwt071relatedpartiespersondataset1.getOrders()) {
                    if (orderItem.isAsc()) {
                        orderParameter[0] = orderItem.getColumn() + ",asc;";
                    } else {
                        orderParameter[0] = orderItem.getColumn() + ",desc;";
                    }
                }
            }
            parameterMap.put("orderRule", orderParameter);
            lwt071relatedpartiespersondataset1.setLwt071RelatedPartiesPersonlwc071NameFullLike(lwt071relatedpartiespersondataset1.getLwt071RelatedPartiesPersonlwc071NameFullLike().replaceAll("/", "//").replaceAll("%", "/%").replaceAll("_", "/_").replaceAll("\\[", "/[").replaceAll("]", "/]"));
            // 查询条件构造器,将排序条件封装成QueryWrapper
            SingleTableQueryGenerator singleTableQueryGenerator = new SingleTableQueryGenerator();
            QueryWrapper<Lwt071RelatedPartiesPerson> queryWrapper = singleTableQueryGenerator.initQueryWrapper(new Lwt071RelatedPartiesPerson(), parameterMap);
            List<Lwt071RelatedPartiesPerson> list = lwt071RelatedPartiesPersonMapper.hussarQuerylwt071RelatedPartiesPersonCondition_1Page(pager, lwt071relatedpartiespersondataset1, queryWrapper);
            lwt071RelatedPartiesPersonPageVO.setData(list);
            lwt071RelatedPartiesPersonPageVO.setCount(pager.getTotal());
            lwt071RelatedPartiesPersonPageVO.setCode(RETURN_CODE);
            return ApiResponse.success(lwt071RelatedPartiesPersonPageVO);
        } catch (Exception e) {
            throw new HussarException("表格查询失败");
        }
    }

    @Override
    public ApiResponse<Lwt071RelatedPartiesPersonPageVO> hussarQuerylwt071RelatedPartiesPersonCondition_1Page_order_custom(Lwt071RelatedPartiesPersonLwt071relatedpartiespersondataset1 lwt071relatedpartiespersondataset1) {
        try {
            Lwt071RelatedPartiesPersonPageVO lwt071RelatedPartiesPersonPageVO = new Lwt071RelatedPartiesPersonPageVO();
            Page<Lwt071RelatedPartiesPerson> pager = new Page<>(lwt071relatedpartiespersondataset1.getCurrent(), lwt071relatedpartiespersondataset1.getSize());
            Map<String, String[]> parameterMap = new HashMap<>();
            String[] orderParameter = new String[1];
            if (lwt071relatedpartiespersondataset1.getOrders() != null) {
                for (OrderItem orderItem : lwt071relatedpartiespersondataset1.getOrders()) {
                    if (orderItem.isAsc()) {
                        orderParameter[0] = orderItem.getColumn() + ",asc;";
                    } else {
                        orderParameter[0] = orderItem.getColumn() + ",desc;";
                    }
                }
            }
            parameterMap.put("orderRule", orderParameter);
            lwt071relatedpartiespersondataset1.setLwt071RelatedPartiesPersonlwc071NameFullLike(lwt071relatedpartiespersondataset1.getLwt071RelatedPartiesPersonlwc071NameFullLike().replaceAll("/", "//").replaceAll("%", "/%").replaceAll("_", "/_").replaceAll("\\[", "/[").replaceAll("]", "/]"));
            // 查询条件构造器,将排序条件封装成QueryWrapper
            SingleTableQueryGenerator singleTableQueryGenerator = new SingleTableQueryGenerator();
            QueryWrapper<Lwt071RelatedPartiesPerson> queryWrapper = singleTableQueryGenerator.initQueryWrapper(new Lwt071RelatedPartiesPerson(), parameterMap);
            List<Lwt071RelatedPartiesPerson> list = lwt071RelatedPartiesPersonMapper.hussarQuerylwt071RelatedPartiesPersonCondition_1Page_order_custom(pager, lwt071relatedpartiespersondataset1, queryWrapper);
            lwt071RelatedPartiesPersonPageVO.setData(list);
            lwt071RelatedPartiesPersonPageVO.setCount(pager.getTotal());
            lwt071RelatedPartiesPersonPageVO.setCode(RETURN_CODE);
            return ApiResponse.success(lwt071RelatedPartiesPersonPageVO);
        } catch (Exception e) {
            throw new HussarException("表格查询失败");
        }
    }
}
